const app = getApp()
let text = require('../../../common/util/text.js')
let util = require('../../../common/util/util.js')
Page({
    data: {
        pain_part:[],
        current:12,
        id:'',
        partscurrent:0,
        resultList:[{cn: '疼痛部位', key: 'pain_part', value: []},
        { cn: '过去24小时内您疼痛最剧烈的程度', key: 'most_violent_degree', value: ''},
        { cn: '过去24小时内您疼痛最轻微的程度。', key: 'slightest_degree', value: ''},  
        { cn: '过去24小时内疼痛的平均程度。', key: 'average_degree_pain', value: ''}, 
        { cn: '目前的疼痛程度', key: 'current_pain_level', value: ''},
        { cn: '疼痛缓解的程度。', key: 'pain_relief', value: ''},  
        { cn: '过去24小时内疼痛对您日常生活的影响', key: 'Impact_daily_life', value: ''},  
        { cn: '24小时内疼痛对您情绪的影响', key: 'Impact_your_mood', value: ''},
        { cn: '过去24小时内疼痛对您行走能力的影响', key: 'influence_walking_ability', value: ''},  
        { cn: '过去24小时内疼痛对您日常工作的影响', key: 'impact_daily_work', value: ''},  
        { cn: '过去24小时内疼痛对您与他人关系的影响', key: 'Influence_relationship', value: ''},
        { cn: '过去24小时内疼痛对您睡眠的影响', key: 'effects_sleep', value: ''},  
        { cn: '过去24小时内疼痛对您生活兴趣的影响', key: 'Influence_life_interest', value: ''}],

    },
    onLoad: function (options) {
      let that =this;
      if(options.id){
        that.setData({
          id:options.id
        })
        that.getResult(options.id)
      }else{
        that.xInit()
      }
    },
    xBack:function(){
      if(this.data.id){
        wx.navigateBack({
          delta:1
        })
      }else{
        wx.reLaunch({
          url: '/pages/navigation/using/index',
        })
      }
    },
    xInit:function () {
        let that = this
        let resultList = that.data.resultList
        wx.cloud.callFunction({
          name: 'evaluation',
          data: {
            action: "get_mixed_standardscoles_info"
          }
        }).then(res => {
          res.result.create_time = util.formatTime_chinese_m(new Date(res.result.create_time))
          res.result.pri_desc = text.text(res.result.pri_desc)
          let newstr=''
          if(app.globalData.user.phone_number){
            const strAry = app.globalData.user.phone_number.split('');
            strAry[3] = 'x';
            strAry[4] = 'x';
            strAry[5] = 'x';
            strAry[6] = 'x';
            newstr =  strAry.join("")
          }
          res.result.gist = res.result.gist ? text.text(res.result.gist):''
          that.setData({
            result:res.result,
            resultList:resultList,
            phone_number:newstr
          })

        })
    },
    getResult:function(id){
      let that = this
      let resultList = that.data.resultList
      wx.cloud.callFunction({
        name: 'evaluation',
        data: {
          action: "get_mixed_standardscoles_info",
          _id: id
        }
      }).then(res => {
        res.result.create_time = util.formatTime_chinese_m(new Date(res.result.create_time))
        res.result.pri_desc = text.text(res.result.pri_desc)
        let newstr=''
        if(app.globalData.user.phone_number){
          const strAry = app.globalData.user.phone_number.split('');
          strAry[3] = 'x';
          strAry[4] = 'x';
          strAry[5] = 'x';
          strAry[6] = 'x';
          newstr =  strAry.join("")
        }
        that.setData({
          result:res.result,
          resultList:resultList,
          phone_number:newstr
        })
      })
  },
    xToSeePRI:function(){
      this.setData({
        show:true
      })
    }
})